<template>
  <el-dialog title="会员升级记录" :close-on-click-modal="false" :visible.sync="visible" fullscreen center>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-form :model="dataForm" ref="dataForm" label-width="140px" size="mini">
      <el-card class="box-card">
        <div class="text item">
          <el-row>
            <el-col :span="6">
              <el-form-item label="会员卡号" prop="complainNum">
                <el-input v-model="dataForm.curCustomerCard" readonly disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="会员姓名" prop="customerName">
                <el-input v-model="dataForm.customerName" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级部门" prop="deptId">
                <el-select v-model="dataForm.deptId" disabled>
                  <el-option v-for="item in deptOptions" :key="item.value" :value="item.value" :label="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级人员" prop="curIntegral">
                <el-input v-model="dataForm.curIntegral" disabled></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="升级前积分" prop="originalIntegral">
                <el-input v-model="dataForm.originalIntegral" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="扣除积分" prop="intergralChange">
                <el-input v-model="dataForm.intergralChange" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级后积分" prop="curIntegral">
                <el-input v-model="dataForm.curIntegral" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级类型" prop="upgradeType">
                <el-select v-model="dataForm.upgradeType" disabled>
                  <el-option v-for="item in upgradeTypeOptions" :key="item.value" :value="item.value" :label="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="升级前会员卡类型" prop="originalCardType">
                <el-select v-model="dataForm.originalCardType" disabled>
                  <el-option v-for="item in cardTypeOptions" :key="item.value" :value="item.value" :label="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级后会员卡类型" prop="curCardType">
                <el-select v-model="dataForm.curCardType" disabled>
                  <el-option v-for="item in cardTypeOptions" :key="item.value" :value="item.value" :label="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="升级日期" prop="upgradeDate">
                <el-date-picker v-model="dataForm.upgradeDate" type="date" disabled></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6"></el-col>
          </el-row>
        </div>
      </el-card>
    </el-form>
  </el-dialog>
</template>

<script>
  import {
    customerComplaintInfo
  } from '@/api/eims/customer-complaint.js'
  import {
    fetchCustomerList
  } from '@/api/eims/customer.js'
  import {
    customerCardRecordDetail
  } from '@/api/eims/customer-upgrade.js'
  import {
    fetchTree
  } from '@/api/admin/dept.js'

  export default {
    data() {
      return {
        visible: false,
        dataForm: {
          complainNum: '',
          complaintsType: '',
          customerId: '',
          customerCard: '',
          customerName: '',
          phone1: '',
          estimatedProcessingDate: '',
          comlainContent: '',
          status: '',
          dealContent: '',
          curIntegral: 0
        },
        complaintsTypeOptions: [{
            value: '01',
            name: '商品质量'
          }, {
            value: '02',
            name: '验光'
          }, {
            value: '03',
            name: '销售'
          }, {
            value: '04',
            name: '加工质量'
          }, {
            value: '05',
            name: '检验'
          },
          {
            value: '06',
            name: '送货'
          }, {
            value: '07',
            name: '服务态度'
          }, {
            value: '08',
            name: '订单失误'
          }, {
            value: '09',
            name: '调整校配'
          }, {
            value: '10',
            name: '时间延误'
          }
        ],
        statusOptions: [{
          value: 2,
          name: '处理中'
        }, {
          value: 1,
          name: '已处理'
        }],
        deptOptions: [],
        upgradeTypeOptions: [{
          value: 1,
          name: '直接升级'
        }, {
          value: 0,
          name: '非直接升级'
        }],
        cardTypeOptions: [{
          value: 1,
          name: '会员卡'
        }, {
          value: 0,
          name: '非会员'
        }]
      }
    },
    methods: {
      init(id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          fetchTree().then(response => {
            if(response.data.code == '0'){
              let resultData = response.data.data
              let list = []
              resultData.forEach(item => {
                list.push({
                  value: item.id,
                  name: item.name
                })
              })
              this.deptOptions = list
            }else{
              this.$message.error(response.data.msg)
            }
          })
          if (this.dataForm.id) {
            customerCardRecordDetail(this.dataForm.id).then(response => {
              if(response.data.code == '0'){
                this.dataForm = response.data.data
              }else{
                this.$message.error(response.data.msg)
              }
            })
          }
        })
      },
    }
  }
</script>

<style>
</style>
